package com.example.easyexcel.controller;

import com.example.easyexcel.service.*;
import com.example.easyexcel.service.AssetTargetInfoAopService;
import com.example.easyexcel.service.AssettargetInfoSingleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/asset")
@RequiredArgsConstructor
public class AssetInfoController {
    private final AssetReportInfoService assetReportInfoService;

    private final AssetTargetInfoService assetTargetInfoService;

    private final AssettargetInfoSingleService assettargetInfoSingleService;

    private final AssetTargetInfoAopService assetTargetInfoAopService;

    private final AssetInterfaceApiInfoService assetInterfaceApiInfoService;

    private final DataIndexService dataIndexService;

    @PostMapping("/import_dataIndex")
    public String importMetricExcel(@RequestParam("file") MultipartFile file) {
        dataIndexService.importMetricExcel(file);
        return "t_data_index表导入成功";
    }
    @PostMapping("/import_assetReportInfo")
    public String importReportExcel(@RequestParam("file") MultipartFile file) {
        assetReportInfoService.importReportExcel(file);
        return "Report表导入成功";
    }

    @PostMapping("/import_assetTargetInfo_ThreadPool")
    public String importTargetExcelThreadPool(@RequestParam("file") MultipartFile file) {
        assetTargetInfoService.importTargetExcel(file);
        return "多线程Target表导入成功";
    }

    @PostMapping("/import_assetTargetInfo_ThreadPool_Aop")
    public String importTargetExcelThreadPoolAop(@RequestParam("file") MultipartFile file) {
        assetTargetInfoAopService.importTargetExcel(file);
        return "多线程Target表-AOP耗时监控导入成功";
    }

    @PostMapping("/import_assetTargetInfo_Single")
    public String importTargetExcelSingle(@RequestParam("file") MultipartFile file) {
        assettargetInfoSingleService.importTargetExcel(file);
        return "单线程Target表导入成功";
    }

    @PostMapping("/import_assetApiInfo")
    public String importApiExcel(@RequestParam("file") MultipartFile file) {
        assetInterfaceApiInfoService.importApiExcel(file); // 启用服务
        return "API表导入成功";
    }
}
